<template>
    <div style="min-width:809px">
        <div v-if="$route.path == '/staff'">
            <div class="vs-search-box">
                <el-form ref="form" :inline="true" :model="paging" label-width="120px">
                    <el-form-item label="工号：">
                        <el-input style="width:200px" v-model="paging.username"></el-input>
                    </el-form-item>
                    <el-form-item label="入职时间：">
                        <el-date-picker style="width:200px" v-model="paging.username" type="date" placeholder="选择日期">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item label="" class="vs-right-btns">
                        <el-button @click="reset">重置</el-button>
                        <el-button @click="handleCurrentChange(1)" type="primary">查询</el-button>
                    </el-form-item>
                    <el-form-item label="手机号码：">
                        <el-input style="width:200px" v-model="paging.username"></el-input>
                    </el-form-item>
                    <el-form-item label="人员来源：">
                        <el-select style="width:200px" clearable v-model="paging.username" placeholder="请选择">
                            <el-option label="推拿" value="1"> </el-option>
                            <el-option label="足疗" value="2"> </el-option>
                            <el-option label="SPA" value="3"> </el-option>
                        </el-select>
                    </el-form-item>

                </el-form>
            </div>
            <div class="vs-table-box">
                <div class="operation-box clear-float">
                    <!-- <div class="title-left"> 分销列表 </div> -->
                    <el-button icon="el-icon-plus" @click="dialogVisible=true" style="margin-left:auto;" type="primary">新增</el-button>
                </div>
                <el-table v-loading="loading" :data="tableData" header-row-class-name="has-gutter-table" style="width: 100%">
                     <el-table-column label="员工头像" min-width="130">
                        <template slot-scope="scope">
                            <el-image class="image-thumbnail" :src="scope.row.url" fit="cover" :preview-src-list="[scope.row.url]" > </el-image>
                        </template>
                    </el-table-column>
                    <el-table-column prop="username" label="姓名"> </el-table-column>
                    <el-table-column prop="code" label="工号" min-width="70"> </el-table-column>
                    <el-table-column prop="create_time" label="员工生日" min-width="150"> </el-table-column>
                    <el-table-column prop="create_time" label="手机号" min-width="150"> </el-table-column>
                    <el-table-column prop="code" label="职位"> </el-table-column>
                    <el-table-column prop="title" label="等级" > </el-table-column>
                    <el-table-column prop="id" label="技能"> </el-table-column>
                    <el-table-column prop="id" label="人员来源"> </el-table-column>
                    <el-table-column prop="create_time" label="入职时间" min-width="150"> </el-table-column>
                    <el-table-column prop="create_time" label="转正日期" min-width="150"> </el-table-column>
                    <el-table-column prop="id" label="备注"> </el-table-column>
                    <el-table-column fixed="right" width="160" label="操作">
                        <template slot-scope="scope">
                            <span @click="setRow(1,scope.row)" class="tab-table-text">编辑</span>
                            <span @click="setRow(2,scope.row)" class="tab-table-text">调出</span>
                            <span @click="setRow(2,scope.row)" class="tab-red-text">离职</span>
                        </template>
                    </el-table-column>
                </el-table>
                <div class="vs-paging-box">
                    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="paging.page" :page-size="paging.limit" layout="sizes,prev, pager, next, jumper" :total="paging.total">
                    </el-pagination>
                </div>
            </div>
        </div>
        <router-view></router-view>
        <el-dialog title="分销记录" :visible.sync="isInfo">
            <!-- width="570px" -->
            <el-table :data="recordList" v-loading="loading2" header-row-class-name="has-gutter-table" style="width: 100%">
                <el-table-column prop="company.title" label="公司名称"> </el-table-column>
                <el-table-column prop="create_time" label="邀请时间"> </el-table-column>
            </el-table>
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="isInfo = false">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
export default {
    data() {
        return {
            recordList: [],
            loading: false,
            loading2: false,
            isBtn: false,
            isInfo: false,
            dialogVisible: false,
            paging: {
                username: '',//姓名
                start_time: '',//开始时间
                end_time: '',//结束时间
                page: 1,
                total: 0,
                limit: 10,
            },
            form: {
                date: "",
            },
            tableData: []
        };
    },
    created() {
        if (this.$route.path == '/staff') {
            this.handleCurrentChange(1);
        }
    },
    methods: {
        async setRow(type, row) {
            this.utils.goUrl('/staffInfo')
            return;
            if (type == 1) {
                this.dialogVisible = true;
                setTimeout(() => {
                    this.ruleForm = Object.assign({}, row);
                }, 200);
            } else if (type == 2) {
                this.isInfo = true;
                this.loading2 = true;
                let { code, data } = await this.$Http.catdistribution({
                    id: row.id
                })
                this.loading2 = false;
                if (code) {
                    this.recordList = data;
                } else this.recordList = [];
            }
        },
        handleClose(dom) {
            this.$refs['ruleForm'].resetFields();
            this.dialogVisible = false;
            dom && dom();
        },
        async repairGetList() {
            this.loading = true;
            let { code, data } = await this.$Http.getDistribution(this.paging);
            this.loading = false;
            if (code) {
                this.tableData = data.data;
                this.paging.total = data.total;
            }
        },
        reset() {//重置
            this.paging = this.$options.data().paging;
            this.form.date = '';
            this.handleCurrentChange(1)
        },
        handleSizeChange(val) {
            this.paging.limit = val;
            this.repairGetList()
        },
        handleCurrentChange(val) {
            this.paging.page = val;
            this.repairGetList()
        }
    },
};
</script>

<style lang="scss" scoped>
.image-thumbnail {
    width: 130px;
    height: 130px;
}
</style>